package com.sxf.controller.blog.admin;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.ModelAndView;

/**
 * 统一处理ajax请求
 * 
 * @author phsxf01
 * 
 */
@Controller
@RequestMapping("blog/admin/ajax")
public class AjaxAdminController {

	@RequestMapping("")
	@ResponseBody
	public ModelAndView doAjax(
			@RequestParam(value = "action", required = true) String action,
			WebRequest request) throws Exception {
		ModelAndView mav = new ModelAndView();

		if ("ajax-tag-search".equals(action)) {
			// 查找或添加文章标签
			String tax = request.getParameter("tax");// post_tag
			String q = request.getParameter("q");// 新标签或查找的标签(测试1标签,测试2标签)
		} else if ("autosave".equals(action)) {
			// 自动保存
			String postId = request.getParameter("post_ID");// post_tag
			request.getParameter("autosavenonce");
			request.getParameter("post_type");
			request.getParameter("autosave");
			request.getParameter("post_title");
			request.getParameter("content");
			request.getParameter("catslist");
			request.getParameter("comment_status");
			request.getParameter("ping_status");
			request.getParameter("excerpt");
			request.getParameter("post_author");
			request.getParameter("user_ID");
		}

		return mav;
	}
}
